package nix.spring.proxy;

import org.junit.Test;

import nix.spring.service.UserService;
import nix.spring.service.UserServiceImpl;

public class Demo1 {

	/**
	 * 动态代理
	 */
	@Test
	public void fun1() {
		
		UserService us = new UserServiceImpl();
		UserServiceProxyFactory factory = new UserServiceProxyFactory(us);
		UserService proxy = factory.getUserServiceProxy();
		proxy.add();
	}
	
	/**
	 * cglib代理
	 */
	@Test
	public void fun2() {
		
		UserServiceProxyFactory2 factory = new UserServiceProxyFactory2();
		UserService proxy = factory.getUserServiceProxy();
		proxy.add();
		// cglib代理为继承代理
		System.out.println(proxy instanceof UserServiceImpl);
	}
}
